Package | ch.fhir.ig.cda-fhir-maps |
Type | StructureMap |
Id | Id |
FHIR Version | R4 |
Source | http://fhir.ch/ig/cda-fhir-maps/http://fhir.ch/ig/cda-fhir-maps/StructureMap-BundleToCdaChEmed.html |
Url | http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaChEmed |
Version | 0.3.0 |
Status | draft |
Date | 2022-02-11T11:14:39+01:00 |
Name | BundleToCdaChEmed |
Experimental | False |
Realm | ch |
Authority | hl7 |
Description | Medication Entries 2020-11-11 Michaela Ziegler, copyright ahdis ag, Apache License CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed- FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html |
Copyright | CC-BY-SA-4.0 |
No resources found
No resources found
Note: links and images are rebased to the (stated) source
map "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaChEmed" = "BundleToCdaChEmed" // Medication Entries // 2020-11-11 Michaela Ziegler, copyright ahdis ag, Apache License // CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed- // FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html uses "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument" alias ClinicalDocument as target uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor" alias AssignedAuthor as target uses "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity" alias AssignedEntity as target uses "http://hl7.org/fhir/cda/StructureDefinition/Author" alias Author as target uses "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization" alias CustodianOrganization as target uses "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS" alias IVL_TS as target uses "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS" alias EIVL_TS as target uses "http://hl7.org/fhir/cda/StructureDefinition/PatientRole" alias PatientRole as target uses "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget" alias RecordTarget as target uses "http://hl7.org/fhir/cda/StructureDefinition/Section" alias Section as target uses "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration" alias SubstanceAdministration as target uses "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS" alias SXPR_TS as target uses "http://hl7.org/fhir/cda/StructureDefinition/Supply" alias Supply as target uses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as source uses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as source uses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as source uses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as source uses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as source uses "http://hl7.org/fhir/StructureDefinition/MedicationStatement" alias MedicationStatement as source uses "http://hl7.org/fhir/StructureDefinition/Dosage" alias Dosage as source imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes" imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda" imports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh" // source: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html) // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2 group AnnotationComment(source note : Annotation, target act : Act) { note -> act.classCode = 'ACT' "ACT"; note -> act.moodCode = 'EVN' "EVN"; note -> act.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.2' "templateId"; note -> act.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.40' "templateId"; note -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.2' "templateId"; note -> act.code as code, code.code = '48767-8', code.codeSystem = '2.16.840.1.113883.6.1', code.displayName = 'Annotation comment', code.codeSystemName = 'LOINC' "code"; note.text as noteText -> act.text as text then { noteText -> text.data = noteText "text"; note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then { extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference"; } "id"; note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference"; }; note -> act.statusCode as code, code.code = 'completed' "statusCode"; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US group ManufacturedMaterialEntryContentModuleStatement(source bundle : Bundle, source medicationStatement : MedicationStatement, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial) { medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT"; medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND"; medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule"; medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId"; medication.code as code then { code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname"; } "name"; medication.code as code then { // #mtpc.no.brandedmedication code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then { extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference"; } "id"; code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference"; code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code"; code where coding.exists() = false -> manufacturedMaterial.code as ce, ce.nullFlavor = 'NA' "nullFlavor"; }; medication.form as form then { form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode"; }; medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then { code -> containerPackagedMedicine.classCode = 'CONT' "CONT"; code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE"; code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code"; code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name"; medication.form as form then { form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode"; }; // Package size medication.amount as amount then { amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then { numerator.value as value -> capacityQuantity.value = value; numerator.code as unit -> capacityQuantity.unit = unit "unit"; }; }; }; medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then { ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then { itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT"; itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND"; itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name"; itemCodeableConcept.coding as coding then { coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode"; }; } "PharmSubstance"; ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity); }; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.34&effectiveDate=2019-12-11T11:31:52&language=en-US group MedicationTreatmentPlanItemEntryContentModule(source bundle : Bundle, source medicationStatement : MedicationStatement, target substanceAdministration : SubstanceAdministration) { medicationStatement -> substanceAdministration.classCode = 'SBADM' "SBADM"; medicationStatement -> substanceAdministration.moodCode = 'INT' "INT"; medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.34' "CH-PHARM-MedicationTreatmentPlanItemEntryContentModule"; medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.7' "IHE-PHARM-MTP"; medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.24' "CCD"; medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7' "PCC-MedicationEntryContentModule"; medicationStatement.identifier as identifier -> substanceAdministration.id as id then IdentifierII(identifier, id) "id"; medicationStatement.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> substanceAdministration.text as text, text.reference as reference then { extension.valueUrl as valueUrl -> reference.value = valueUrl; } "narrativeLink"; medicationStatement where extension.where(url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists().not() -> substanceAdministration.text as text, text.reference as reference then { medicationStatement -> reference.value = '#refpdf' "referencetopdf"; } "cat1narrativelink"; medicationStatement -> substanceAdministration.statusCode as statusCode, statusCode.code = 'completed' "code"; medicationStatement.contained as medication where ('#' + $this.id) in %medicationStatement.medicationReference.reference -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then { medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-TemplateId"; medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-TemplateId"; medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModuleStatement(bundle, medicationStatement, medication, manufacturedMaterial) "manufacturedMaterial"; }; // TODO: AUTHOR1 Medication Treatment Plan Author medicationStatement where dosage.count() = 1 then { medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose"; } "onylonedosage"; // dosage for normal dosing, as no sequences are present there medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal') then DosageInstructionsStartStopFrequencySubstanceAdministration(dosage, substanceAdministration) "DosageSubstanceAdministration"; // dosage for split dosing (with sequences): effectiveTime (start/stop) & routeCode medicationStatement.dosage first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship then DosageInstructionsEntryStartStopRoute(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration"; // dosage for split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeSubstanceAdministration(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration"; medicationStatement.reasonCode as reasonCode -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'RSON', entryRelationship.observation as observation then TreatmentReasonEntryContentModule(reasonCode, observation) "TreatmentReasonEntryContentModule"; medicationStatement.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference"; // https://github.com/ehealthsuisse/ch-emed/issues/56 medicationStatement -> substanceAdministration.repeatNumber as repeatNumber, repeatNumber.nullFlavor = 'NI' "repeatNumberDefault"; // TODO: Patient Medication Instructions Contains 1.3.6.1.4.1.19376.1.5.3.1.4.3 IHE Patient Medication Instructions (DYNAMIC) medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule"; medicationStatement.note as note -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment"; medicationStatement.extension as extension where $this.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-substitution' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionStatement(extension, act) "Substitution"; } // TODO: Tapered Dose // medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.8' "taperedDose"; // source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal // target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35 // dosage for normal dosing (without sequences) (Statement, Prescription) group DosageInstructionsStartStopFrequencySubstanceAdministration(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) { dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose"; dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd"; dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenNormal(dosage, substanceAdministration) "effectiveTimeWhen"; dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode); dosage as dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity"; } // source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split // target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36 // dosage for split dosing: effectiveTime (start/stop) & routeCode (Statement, Prescription) group DosageInstructionsEntryStartStopRoute(source dosage : Dosage, target substanceAdministration : substanceAdministration, target entry : entryRelationship) { // if the FHIR doucment has no dosage templateId -> create templateId for split dose dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.9' "splitDose"; dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd"; dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode); } // source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split // target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36 // dosage for split dosing: sequence number, effectiveTime (when), dose quantity, consumable (Statement, Prescription) group DosageInstructionsEntryDosageChangeSubstanceAdministration(source dosage : Dosage, target substanceAdministration : substanceAdministration, target entry : entryRelationship) { dosage.sequence as sequence -> entry.sequenceNumber as sequenceNumber, sequenceNumber.value = sequence; dosage -> entry.substanceAdministration as substanceAdministration, substanceAdministration.classCode = 'SBADM', substanceAdministration.moodCode = 'INT' then { dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenSplit(dosage, substanceAdministration) "effectiveTimeWhen"; dosage as dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity"; dosage as dosage -> substanceAdministration as substanceAdministration, substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable"; } "dosage"; } // effective time low and high for dosage (Statement, Prescription) group EffectiveTimeStartEnd(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) { dosage.timing as timing then { timing.repeat as repeat then { repeat.bounds : Period as bounds -> substanceAdministration.effectiveTime = create('IVL_TS') as effectiveTime then { bounds.start as start -> effectiveTime.low as low then DateTS(start, low) "low"; bounds where start.exists().not() -> effectiveTime.low as low, low.nullFlavor = 'UNK' "NullFlavorLow"; bounds.end as end -> effectiveTime.high as high then DateTS(end, high) "high"; bounds where end.exists().not() -> effectiveTime.high as high, high.nullFlavor = 'UNK' "NullFlavorhigh"; }; }; }; } // dose quantity for dosage (application schema) (Statement) group DoseQuantity(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) { dosage.doseAndRate as doseAndRate -> substanceAdministration.doseQuantity as doseQuantity then { doseAndRate.dose : Quantity as quantity then { quantity.value as value -> doseQuantity.value = value; quantity.code as code -> doseQuantity.unit = code; } "quantity"; } "doseQuantity"; } // source: reasonCode Coding (e.g. http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-medicationstatement) // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.41 // Treatment Reason (Statement, Prescription) group TreatmentReasonEntryContentModule(source reasonCode : Coding, target observation : Observation) { reasonCode -> observation.classCode = 'OBS' "OBS"; reasonCode -> observation.moodCode = 'EVN' "EVN"; reasonCode -> observation.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.41' "TreatmentReasonEntryContentModule"; reasonCode -> observation.code as code, code.code = '75326-9', code.codeSystem = '2.16.840.1.113883.6.1', code.displayName = 'Problem', code.codeSystemName = 'LOINC' "code"; reasonCode.text as reasonText -> observation.text as text then { reasonText -> text.data = reasonText "text"; reasonCode.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then { extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference"; } "id"; reasonCode where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference"; }; reasonCode -> observation.statusCode as code, code.code = 'completed' "statusCode"; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html // target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.45&effectiveDate=2017-01-10T15:34:25&language=en-US group MTPReferenceEntryContentModule(source ext : Extension, target substanceAdministration : SubstanceAdministration) { ext -> substanceAdministration.classCode = 'SBADM' "SBADM"; ext -> substanceAdministration.moodCode = 'INT' "INT"; ext -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.10' "referenceTo-MTP-PlanItemGeneralSpecificationTemplateId"; ext -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.45' "CH-PHARM-templateId"; ext.extension as extension where $this.url = 'id' then { extension.valueIdentifier as valueIdentifier -> substanceAdministration.id as id then IdentifierII(valueIdentifier, id) "id"; } "id"; ext -> substanceAdministration.code as code, code.code = 'MTPItem', code.codeSystem = '1.3.6.1.4.1.19376.1.9.2.2', code.displayName = 'Medication Treatment Plan Item', code.codeSystemName = 'IHE Pharmacy Item Type List' "code"; ext -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable"; ext.extension as extension where $this.url = 'externalDocumentId' then { extension.valueIdentifier as valueIdentifier -> substanceAdministration.reference as reference, reference.typeCode = 'XCRPT', reference.externalDocument as externalDocument, externalDocument.id as id then IdentifierII(valueIdentifier, id) "id"; } "externalDocumentId"; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-dosage-nonstructured.html // target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.52 // Dosage Instruction (Statement, Prescription) group DosageInstructionsNonStructuredEntryContentModule(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) { dosage -> substanceAdministration.classCode = 'SBADM' "SBADM"; dosage -> substanceAdministration.moodCode = 'INT' "INT"; dosage -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.52' "templateId"; dosage.text as noteText -> substanceAdministration.text as text then { noteText -> text.data = noteText "text"; dosage.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then { extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference"; } "id"; dosage where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference"; }; dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable"; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html // target: Substitution act Contains 1.3.6.1.4.1.19376.1.9.1.3.9.2 IHE Substitution Act Content Module // Substitution (Dispense) group SubstitutionDispense(source substitution : Substitution, target act : Act) { substitution -> act.classCode = 'ACT' "ACT"; substitution -> act.moodCode = 'EVN' "EVN"; substitution -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.2' "templateId"; substitution.type as type -> act.code as code then CodeableConceptCE(type, code) "substitution"; substitution -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode"; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US group ManufacturedMaterialEntryContentModuleDispense(source bundle : Bundle, source medicationDispense : MedicationDispense, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial) { medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT"; medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND"; medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule"; medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId"; medication.code as code then { code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname"; } "name"; medication.code as code then { // #dis.no.brandedmedication code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then { extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference"; } "id"; code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference"; code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code"; }; medication.form as form then { form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode"; }; medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then { code -> containerPackagedMedicine.classCode = 'CONT' "CONT"; code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE"; code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code"; code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name"; medication.form as form then { form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode"; }; // Package size medication.amount as amount then { amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then { numerator.value as value -> capacityQuantity.value = value; numerator.code as unit -> capacityQuantity.unit = unit "unit"; }; }; }; medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then { ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then { itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT"; itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND"; itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name"; itemCodeableConcept.coding as coding then { coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode"; }; } "PharmSubstance"; ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity); }; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.42 group DispenseItemEntryContentModule(source bundle : Bundle, source medicationDispense : MedicationDispense, target supply : Supply) { medicationDispense -> supply.classCode = 'SPLY' "SPLY"; medicationDispense -> supply.moodCode = 'EVN' "EVN"; medicationDispense -> supply.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.42' "CH-PHARM-DispenseItemEntryContentModule"; medicationDispense -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.4' "IHE-PHARM-DIS"; medicationDispense -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.3' "supplyEntry"; medicationDispense -> supply.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.34' "CCD"; medicationDispense.identifier as identifier -> supply.id as id then IdentifierII(identifier, id) "id"; medicationDispense.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> supply.text as text, text.reference as reference then { extension.valueUrl as valueUrl -> reference.value = valueUrl; } "narrativeLink"; medicationDispense where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> supply.text as text, text.reference as reference, text.reference as reference, reference.value = '#refpdf' "reference"; medicationDispense.contained as medication where ('#' + $this.id) in %medicationDispense.medicationReference.reference -> supply.product as product, product.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then { medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-TemplateId"; medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-TemplateId"; medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModuleDispense(bundle, medicationDispense, medication, manufacturedMaterial) "manufacturedMaterial"; }; // TODO: AUTHOR1 Medication Treatment Plan Author medicationDispense.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference"; // #24 missing template it if ch-emed-dosage-nonstructured medicationDispense where dosageInstruction.count() = 1 then { medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose"; } "onylonedosage"; // dosage for normal dosing, as no sequences are present there medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal') then DosageInstructionsStartStopFrequencySupply(dosage, supply) "DosageSubstanceAdministration"; // dosage for split dosing, as sequences are present there medicationDispense -> supply.entryRelationship as entryRelationship then { medicationDispense -> entryRelationship.substanceAdministration as substanceAdministration then { // split dosing (with sequences): effectiveTime (start/stop) & routeCode & consumable medicationDispense.dosageInstruction first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration then DosageInstructionsEntryStartStopRouteConsumable(dosage, entryRelationship, substanceAdministration) "DosageSubstanceAdministration"; // split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeEntryRelationship(dosage, entryRelationship) "DosageSubstanceAdministration"; } "substanceAdministration"; } "entryRelationship"; // TODO: Precondition Criterion medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule"; // Number of packages medicationDispense.quantity as quantity -> supply.quantity as supplyQuantity then { quantity.value as value -> supplyQuantity.value = value; }; medicationDispense.note as note -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment"; medicationDispense.substitution as substitution -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionDispense(substitution, act) "Substitution"; } // source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal // target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35 // dosage for normal dosing (without sequences) (Dispense) group DosageInstructionsStartStopFrequencySupply(source dosage : Dosage, target supply : Supply) { dosage -> supply.entryRelationship as entryRelationship then { dosage -> entryRelationship.typeCode = 'COMP' "COMP"; dosage -> entryRelationship.substanceAdministration as substanceAdministration then { dosage -> substanceAdministration.classCode = 'SBADM' "SBADM"; dosage -> substanceAdministration.moodCode = 'INT' "INT"; dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.6' "templateId"; dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose"; dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd"; dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenNormal(dosage, substanceAdministration) "effectiveTimeWhen"; dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode); dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity"; dosage -> substanceAdministration as substanceAdministration, substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable"; } "substanceAdministration"; } "entryRelationship"; } // source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split // target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36 // dosage for split dosing: effectiveTime (start/stop) & routeCode & consumable (Dispense) group DosageInstructionsEntryStartStopRouteConsumable(source dosage : Dosage, target entryRelationship : entryRelationship, target substanceAdministration : SubstanceAdministration) { dosage -> entryRelationship.typeCode = 'COMP' "COMP"; dosage -> substanceAdministration.classCode = 'SBADM' "SBADM"; dosage -> substanceAdministration.moodCode = 'INT' "INT"; dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.6' "templateId"; dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.9' "splitDose"; dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd"; dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode); dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable"; } // source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split // target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36 // dosage for split dosing: sequence number, effectiveTime (when), dose quantity, consumable (Dispense) group DosageInstructionsEntryDosageChangeEntryRelationship(source dosage : Dosage, target entryRelationship : entryRelationship) { dosage.sequence as sequence -> entryRelationship.sequenceNumber as sequenceNumber, sequenceNumber.value = sequence; dosage -> entryRelationship.substanceAdministration as substanceAdministration, substanceAdministration.classCode = 'SBADM', substanceAdministration.moodCode = 'INT' then { dosage as dosage -> substanceAdministration then EffectiveTimeWhenSplit(dosage, substanceAdministration) "effectiveTimeWhen"; dosage as dosage -> substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity"; dosage as dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable"; } "dosage"; } // effective time when for normal dosage (Dispense, Statement, Prescription) group EffectiveTimeWhenNormal(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) { dosage.timing as timing then { timing.repeat as repeat then { repeat where $this.when.count() = 1 -> substanceAdministration.effectiveTime = create('EIVL_TS') as effectiveTime, effectiveTime.operator = 'A' then { repeat.when as when -> effectiveTime.event as event, event.code = when; } "when"; repeat where $this.when.count() > 1 -> substanceAdministration.effectiveTime = create('SXPR_TS') as effectiveTime, effectiveTime.operator = 'A' then { repeat.when first as when -> effectiveTime.comp = create('EIVL_TS') as comp then { when -> comp.event as event, event.code = when "when"; } "comp"; repeat.when not_first as when -> effectiveTime.comp = create('EIVL_TS') as comp, comp.operator = 'I' then { when -> comp.event as event, event.code = when "when"; } "compnotfirst"; } "when"; }; }; } // effective time when for split dosage (Dispense, Statement, Prescription) group EffectiveTimeWhenSplit(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) { dosage.timing as timing then { timing.repeat as repeat then { repeat where $this.when.count() = 1 -> substanceAdministration.effectiveTime = create('EIVL_TS') as effectiveTime then { repeat.when as when -> effectiveTime.event as event, event.code = when; } "when"; repeat where $this.when.count() > 1 -> substanceAdministration.effectiveTime = create('SXPR_TS') as effectiveTime, effectiveTime.operator = 'A' then { repeat.when first as when -> effectiveTime.comp = create('EIVL_TS') as comp then { when -> comp.event as event, event.code = when "when"; } "comp"; repeat.when not_first as when -> effectiveTime.comp = create('EIVL_TS') as comp, comp.operator = 'I' then { when -> comp.event as event, event.code = when "when"; } "compnotfirst"; } "when"; }; }; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html // target: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module group SubstitutionRequest(source substitution : Substitution, target act : Act) { substitution -> act.classCode = 'ACT' "ACT"; substitution -> act.moodCode = 'DEF' "DEF"; substitution -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.1' "templateId"; substitution.allowedCodeableConcept as allowedCC -> act.code as code then CodeableConceptCE(allowedCC, code) "substitution"; substitution -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode"; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html // target: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module group SubstitutionStatement(source extension : Extension, target act : Act) { extension -> act.classCode = 'ACT' "ACT"; extension -> act.moodCode = 'DEF' "DEF"; extension -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.1' "templateId"; extension.valueCodeableConcept as valueCC -> act.code as code then CodeableConceptCE(valueCC, code) "extension"; extension -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode"; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38 group PrescribedQuantity(source dispenseRequest : DispenseRequest, target supply : Supply) { dispenseRequest -> supply.classCode = 'SPLY' "SPLY"; dispenseRequest -> supply.moodCode = 'RQO' "RQO"; dispenseRequest -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.8' "templateId"; dispenseRequest -> supply.independentInd as independentInd, independentInd.value = 'false' "independentInd"; // Number of packages dispenseRequest.quantity as quantity -> supply.quantity as quant then { quantity.value as value -> quant.value = value; }; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38 group PrescribedQuantityUnit(source dispenseRequest : DispenseRequest, target supply : Supply) { dispenseRequest -> supply.classCode = 'SPLY' "SPLY"; dispenseRequest -> supply.moodCode = 'RQO' "RQO"; dispenseRequest -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.8' "TemplateId"; dispenseRequest -> supply.independentInd as independentInd, independentInd.value = 'false' "independentInd"; // Number of packages dispenseRequest.quantity as quantity -> supply.quantity as quant then { quantity.value as value -> quant.value = value; quantity.unit as unit -> quant.unit = unit; }; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33 group ManufacturedMaterialEntryContentModulePrescription(source bundle : Bundle, source medicationRequest : MedicationRequest, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial, target substanceAdministration : SubstanceAdministration) { medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT"; medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND"; medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule"; medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId"; medication.code as code then { code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname"; } "name"; medication.code as code then { // #pre.no.brandedmedication code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then { extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference"; } "id"; code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference"; code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code"; }; medication.form as form then { form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode"; }; medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then { code -> containerPackagedMedicine.classCode = 'CONT' "CONT"; code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE"; code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code"; code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name"; medication.form as form then { form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode"; }; // Package size medication.amount as amount then { amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then { numerator.value as value -> capacityQuantity.value = value; numerator.code as unit -> capacityQuantity.unit = unit "unit"; }; // IHE-DIS: Case 1: If the product-element contains package information, the unit attribute is not be present medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.supply as supply then PrescribedQuantity(dispenseRequest, supply) "PrescribedQuantity"; }; // IHE-DIS: Case 2: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system medication where $this.amount.exists() = false then { medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.supply as supply then PrescribedQuantityUnit(dispenseRequest, supply) "PrescribedQuantityUnit"; } "noAmount"; }; medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then { ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then { itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT"; itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND"; itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name"; itemCodeableConcept.coding as coding then { coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode"; }; } "PharmSubstance"; ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity); }; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.43 group PrescriptionItemEntryContentModule(source bundle : Bundle, source medicationRequest : MedicationRequest, target substanceAdministration : SubstanceAdministration) { medicationRequest -> substanceAdministration.classCode = 'SBADM' "SBADM"; medicationRequest -> substanceAdministration.moodCode = 'INT' "INT"; medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.43' "CH-PHARM-PrescriptionItemEntryContentModule"; medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.2' "PrescriptionItemEntryTemplateId"; medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.24' "CCD"; medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7' "PCC-MedicationEntryContentModule"; medicationRequest.identifier as identifier -> substanceAdministration.id as id then IdentifierII(identifier, id) "id"; medicationRequest.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> substanceAdministration.text as text, text.reference as reference then { extension.valueUrl as valueUrl -> reference.value = valueUrl; } "narrativeLink"; medicationRequest where extension.where(url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists().not() -> substanceAdministration.text as text, text.reference as reference then { medicationRequest -> reference.value = '#refpdf' "referencetopdf"; } "cat1narrativelink"; medicationRequest -> substanceAdministration.statusCode as statusCode, statusCode.code = 'completed' "code"; medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.repeatNumber as repeatNumber then { dispenseRequest.numberOfRepeatsAllowed as number -> repeatNumber.value = number "repeatNumber"; dispenseRequest where numberOfRepeatsAllowed.exists() = false -> repeatNumber.nullFlavor = 'NI' "repeatNumberNull"; }; medicationRequest.contained as medication where ('#' + $this.id) in %medicationRequest.medicationReference.reference -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then { medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-templateId"; medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-templateId"; medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModulePrescription(bundle, medicationRequest, medication, manufacturedMaterial, substanceAdministration) "manufacturedMaterial"; }; // TODO: AUTHOR1 Medication Treatment Plan Author medicationRequest where dosageInstruction.count() = 1 then { medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose"; } "onylonedosage"; medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal-medicationrequest') then DosageInstructionsStartStopFrequencySubstanceAdministration(dosage, substanceAdministration) "DosageSubstanceAdministration"; // dosage for split dosing (with sequences): effectiveTime (start/stop) & routeCode medicationRequest.dosageInstruction first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split-medicationrequest') -> substanceAdministration.entryRelationship as entryRelationship then DosageInstructionsEntryStartStopRoute(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration"; // dosage for split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split-medicationrequest') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeSubstanceAdministration(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration"; medicationRequest.reasonCode as reasonCode -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'RSON', entryRelationship.observation as observation then TreatmentReasonEntryContentModule(reasonCode, observation) "TreatmentReasonEntryContentModule"; medicationRequest.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference"; // TODO: Patient Medication Instructions Contains 1.3.6.1.4.1.19376.1.5.3.1.4.3 IHE Patient Medication Instructions (DYNAMIC) medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule"; medicationRequest.note as note -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment"; medicationRequest.substitution as substitution -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionRequest(substitution, act) "Substitution"; } // source: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-observation.html // target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.44 group PharmaceuticalAdviceItemEntryContentModule(source bundle : Bundle, source fhirobservation : Observation, target cdaobservation : Observation) { fhirobservation -> cdaobservation.classCode = 'OBS' "OBS"; fhirobservation -> cdaobservation.moodCode = 'EVN' "EVN"; fhirobservation -> cdaobservation.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.3' "IHE-PHARM-PADV"; fhirobservation -> cdaobservation.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.44' "CH-PHARM-PharmaceuticalAdviceItemEntryContentModule"; fhirobservation.identifier as identifier -> cdaobservation.id as id then IdentifierII(identifier, id) "id"; fhirobservation.code as fhirCode -> cdaobservation.code as cdaCode then CodeableConceptCE(fhirCode, cdaCode); fhirobservation -> cdaobservation.statusCode as statusCode, statusCode.code = 'completed' "code"; fhirobservation.effectiveDateTime as effectiveDateTime -> cdaobservation.effectiveTime as effectiveTime then { effectiveDateTime -> effectiveTime.value = effectiveDateTime "value"; } "effectiveTime"; fhirobservation.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> cdaobservation.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference"; fhirobservation.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-medicationstatement-changed' -> cdaobservation.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR' then { bundle.entry as entry then { entry.fullUrl where ($this in %extension.valueReference.reference) and $this.startsWith('urn:uuid') then { entry.resource as medicationStatement where $this.ofType(FHIR.MedicationStatement) -> entryRelationship.substanceAdministration as substanceAdministration then MedicationTreatmentPlanItemEntryContentModule(bundle, medicationStatement, substanceAdministration) "MedicationStatement"; } "fullUrlAsUuid"; entry.resource as medicationStatement where $this.ofType(FHIR.MedicationStatement) and (('MedicationStatement' + '/' + $this.id) in %extension.valueReference.reference) -> entryRelationship.substanceAdministration as substanceAdministration then MedicationTreatmentPlanItemEntryContentModule(bundle, medicationStatement, substanceAdministration) "MedicationStatement"; }; } "changedmtp"; fhirobservation.note as note then { note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> cdaobservation.text as text, text.reference as reference then { extension.valueUrl as valueUrl -> reference.value = valueUrl; } "narrativeLink"; note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> cdaobservation.text as text, text.reference as reference, reference.value = '#refpdf' "reference"; }; fhirobservation.note as note -> cdaobservation.text as text then { note.text as noteText -> text.data = noteText; note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then { extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference"; } "id"; note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference"; } "text"; }
{
"resourceType" : "StructureMap",
"id" : "BundleToCdaChEmed",
"meta" : {
"versionId" : "2",
"lastUpdated" : "2021-11-04T13:41:21.790+01:00"
},
"text" : {
"status" : "generated",
"div" : "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n <pre>map "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaChEmed" = "BundleToCdaChEmed"\n\n\n// Medication Entries\n// 2020-11-11 Michaela Ziegler, copyright ahdis ag, Apache License\n// CDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed-\n// FHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html\n\nuses "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument" alias ClinicalDocument as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor" alias AssignedAuthor as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity" alias AssignedEntity as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/Author" alias Author as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization" alias CustodianOrganization as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS" alias IVL_TS as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS" alias EIVL_TS as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/PatientRole" alias PatientRole as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget" alias RecordTarget as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/Section" alias Section as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration" alias SubstanceAdministration as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS" alias SXPR_TS as target\nuses "http://hl7.org/fhir/cda/StructureDefinition/Supply" alias Supply as target\nuses "http://hl7.org/fhir/StructureDefinition/Bundle" alias Bundle as source\nuses "http://hl7.org/fhir/StructureDefinition/Composition" alias Composition as source\nuses "http://hl7.org/fhir/StructureDefinition/Patient" alias Patient as source\nuses "http://hl7.org/fhir/StructureDefinition/Practitioner" alias Practitioner as source\nuses "http://hl7.org/fhir/StructureDefinition/Organization" alias Organization as source\nuses "http://hl7.org/fhir/StructureDefinition/MedicationStatement" alias MedicationStatement as source\nuses "http://hl7.org/fhir/StructureDefinition/Dosage" alias Dosage as source\n\nimports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes"\nimports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda"\nimports "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh"\n\n// source: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html)\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2\ngroup AnnotationComment(source note : Annotation, target act : Act) {\n note -> act.classCode = 'ACT' "ACT";\n note -> act.moodCode = 'EVN' "EVN";\n note -> act.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.2' "templateId";\n note -> act.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.40' "templateId";\n note -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.2' "templateId";\n note -> act.code as code, code.code = '48767-8', code.codeSystem = '2.16.840.1.113883.6.1', code.displayName = 'Annotation comment', code.codeSystemName = 'LOINC' "code";\n note.text as noteText -> act.text as text then {\n noteText -> text.data = noteText "text";\n note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then {\n extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference";\n } "id";\n note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference";\n };\n note -> act.statusCode as code, code.code = 'completed' "statusCode";\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US\ngroup ManufacturedMaterialEntryContentModuleStatement(source bundle : Bundle, source medicationStatement : MedicationStatement, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial) {\n medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT";\n medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND";\n medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule";\n medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId";\n medication.code as code then {\n code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname";\n } "name";\n medication.code as code then {\n // #mtpc.no.brandedmedication\n code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then {\n extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference";\n } "id";\n code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference";\n code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code";\n code where coding.exists() = false -> manufacturedMaterial.code as ce, ce.nullFlavor = 'NA' "nullFlavor";\n };\n medication.form as form then {\n form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode";\n };\n medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then {\n code -> containerPackagedMedicine.classCode = 'CONT' "CONT";\n code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE";\n code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code";\n code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name";\n medication.form as form then {\n form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode";\n };\n // Package size\n medication.amount as amount then {\n amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then {\n numerator.value as value -> capacityQuantity.value = value;\n numerator.code as unit -> capacityQuantity.unit = unit "unit";\n };\n };\n };\n medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then {\n ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then {\n itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT";\n itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND";\n itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name";\n itemCodeableConcept.coding as coding then {\n coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode";\n };\n } "PharmSubstance";\n ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity);\n };\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.34&effectiveDate=2019-12-11T11:31:52&language=en-US\ngroup MedicationTreatmentPlanItemEntryContentModule(source bundle : Bundle, source medicationStatement : MedicationStatement, target substanceAdministration : SubstanceAdministration) {\n medicationStatement -> substanceAdministration.classCode = 'SBADM' "SBADM";\n medicationStatement -> substanceAdministration.moodCode = 'INT' "INT";\n medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.34' "CH-PHARM-MedicationTreatmentPlanItemEntryContentModule";\n medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.7' "IHE-PHARM-MTP";\n medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.24' "CCD";\n medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7' "PCC-MedicationEntryContentModule";\n medicationStatement.identifier as identifier -> substanceAdministration.id as id then IdentifierII(identifier, id) "id";\n medicationStatement.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> substanceAdministration.text as text, text.reference as reference then {\n extension.valueUrl as valueUrl -> reference.value = valueUrl;\n } "narrativeLink";\n medicationStatement where extension.where(url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists().not() -> substanceAdministration.text as text, text.reference as reference then {\n medicationStatement -> reference.value = '#refpdf' "referencetopdf";\n } "cat1narrativelink";\n medicationStatement -> substanceAdministration.statusCode as statusCode, statusCode.code = 'completed' "code";\n medicationStatement.contained as medication where ('#' + $this.id) in %medicationStatement.medicationReference.reference -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then {\n medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-TemplateId";\n medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-TemplateId";\n medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModuleStatement(bundle, medicationStatement, medication, manufacturedMaterial) "manufacturedMaterial";\n };\n // TODO: AUTHOR1 Medication Treatment Plan Author\n medicationStatement where dosage.count() = 1 then {\n medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";\n } "onylonedosage";\n // dosage for normal dosing, as no sequences are present there\n medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal') then DosageInstructionsStartStopFrequencySubstanceAdministration(dosage, substanceAdministration) "DosageSubstanceAdministration";\n // dosage for split dosing (with sequences): effectiveTime (start/stop) & routeCode\n medicationStatement.dosage first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship then DosageInstructionsEntryStartStopRoute(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration";\n // dosage for split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable\n medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeSubstanceAdministration(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration";\n medicationStatement.reasonCode as reasonCode -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'RSON', entryRelationship.observation as observation then TreatmentReasonEntryContentModule(reasonCode, observation) "TreatmentReasonEntryContentModule";\n medicationStatement.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";\n // https://github.com/ehealthsuisse/ch-emed/issues/56\n medicationStatement -> substanceAdministration.repeatNumber as repeatNumber, repeatNumber.nullFlavor = 'NI' "repeatNumberDefault";\n // TODO: Patient Medication Instructions Contains 1.3.6.1.4.1.19376.1.5.3.1.4.3 IHE Patient Medication Instructions (DYNAMIC)\n medicationStatement.dosage as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule";\n medicationStatement.note as note -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment";\n medicationStatement.extension as extension where $this.url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-substitution' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionStatement(extension, act) "Substitution";\n}\n\n// TODO: Tapered Dose\n// medicationStatement -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.8' "taperedDose";\n// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal\n// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35\n// dosage for normal dosing (without sequences) (Statement, Prescription)\ngroup DosageInstructionsStartStopFrequencySubstanceAdministration(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {\n dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";\n dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd";\n dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenNormal(dosage, substanceAdministration) "effectiveTimeWhen";\n dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode);\n dosage as dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity";\n}\n\n// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split\n// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36\n// dosage for split dosing: effectiveTime (start/stop) & routeCode (Statement, Prescription)\ngroup DosageInstructionsEntryStartStopRoute(source dosage : Dosage, target substanceAdministration : substanceAdministration, target entry : entryRelationship) {\n // if the FHIR doucment has no dosage templateId -> create templateId for split dose\n dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.9' "splitDose";\n dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd";\n dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode);\n}\n\n// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split\n// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36\n// dosage for split dosing: sequence number, effectiveTime (when), dose quantity, consumable (Statement, Prescription)\ngroup DosageInstructionsEntryDosageChangeSubstanceAdministration(source dosage : Dosage, target substanceAdministration : substanceAdministration, target entry : entryRelationship) {\n dosage.sequence as sequence -> entry.sequenceNumber as sequenceNumber, sequenceNumber.value = sequence;\n dosage -> entry.substanceAdministration as substanceAdministration, substanceAdministration.classCode = 'SBADM', substanceAdministration.moodCode = 'INT' then {\n dosage as dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenSplit(dosage, substanceAdministration) "effectiveTimeWhen";\n dosage as dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity";\n dosage as dosage -> substanceAdministration as substanceAdministration, substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";\n } "dosage";\n}\n\n// effective time low and high for dosage (Statement, Prescription)\ngroup EffectiveTimeStartEnd(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {\n dosage.timing as timing then {\n timing.repeat as repeat then {\n repeat.bounds : Period as bounds -> substanceAdministration.effectiveTime = create('IVL_TS') as effectiveTime then {\n bounds.start as start -> effectiveTime.low as low then DateTS(start, low) "low";\n bounds where start.exists().not() -> effectiveTime.low as low, low.nullFlavor = 'UNK' "NullFlavorLow";\n bounds.end as end -> effectiveTime.high as high then DateTS(end, high) "high";\n bounds where end.exists().not() -> effectiveTime.high as high, high.nullFlavor = 'UNK' "NullFlavorhigh";\n };\n };\n };\n}\n\n// dose quantity for dosage (application schema) (Statement)\ngroup DoseQuantity(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {\n dosage.doseAndRate as doseAndRate -> substanceAdministration.doseQuantity as doseQuantity then {\n doseAndRate.dose : Quantity as quantity then {\n quantity.value as value -> doseQuantity.value = value;\n quantity.code as code -> doseQuantity.unit = code;\n } "quantity";\n } "doseQuantity";\n}\n\n// source: reasonCode Coding (e.g. http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-medicationstatement)\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.41\n// Treatment Reason (Statement, Prescription)\ngroup TreatmentReasonEntryContentModule(source reasonCode : Coding, target observation : Observation) {\n reasonCode -> observation.classCode = 'OBS' "OBS";\n reasonCode -> observation.moodCode = 'EVN' "EVN";\n reasonCode -> observation.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.41' "TreatmentReasonEntryContentModule";\n reasonCode -> observation.code as code, code.code = '75326-9', code.codeSystem = '2.16.840.1.113883.6.1', code.displayName = 'Problem', code.codeSystemName = 'LOINC' "code";\n reasonCode.text as reasonText -> observation.text as text then {\n reasonText -> text.data = reasonText "text";\n reasonCode.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then {\n extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference";\n } "id";\n reasonCode where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference";\n };\n reasonCode -> observation.statusCode as code, code.code = 'completed' "statusCode";\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-ext-treatmentplan.html\n// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.45&effectiveDate=2017-01-10T15:34:25&language=en-US\ngroup MTPReferenceEntryContentModule(source ext : Extension, target substanceAdministration : SubstanceAdministration) {\n ext -> substanceAdministration.classCode = 'SBADM' "SBADM";\n ext -> substanceAdministration.moodCode = 'INT' "INT";\n ext -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.10' "referenceTo-MTP-PlanItemGeneralSpecificationTemplateId";\n ext -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.45' "CH-PHARM-templateId";\n ext.extension as extension where $this.url = 'id' then {\n extension.valueIdentifier as valueIdentifier -> substanceAdministration.id as id then IdentifierII(valueIdentifier, id) "id";\n } "id";\n ext -> substanceAdministration.code as code, code.code = 'MTPItem', code.codeSystem = '1.3.6.1.4.1.19376.1.9.2.2', code.displayName = 'Medication Treatment Plan Item', code.codeSystemName = 'IHE Pharmacy Item Type List' "code";\n ext -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";\n ext.extension as extension where $this.url = 'externalDocumentId' then {\n extension.valueIdentifier as valueIdentifier -> substanceAdministration.reference as reference, reference.typeCode = 'XCRPT', reference.externalDocument as externalDocument, externalDocument.id as id then IdentifierII(valueIdentifier, id) "id";\n } "externalDocumentId";\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-dosage-nonstructured.html\n// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?section=templates&id=2.16.756.5.30.1.1.10.4.52\n// Dosage Instruction (Statement, Prescription)\ngroup DosageInstructionsNonStructuredEntryContentModule(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {\n dosage -> substanceAdministration.classCode = 'SBADM' "SBADM";\n dosage -> substanceAdministration.moodCode = 'INT' "INT";\n dosage -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.52' "templateId";\n dosage.text as noteText -> substanceAdministration.text as text then {\n noteText -> text.data = noteText "text";\n dosage.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then {\n extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference";\n } "id";\n dosage where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference";\n };\n dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html\n// target: Substitution act Contains 1.3.6.1.4.1.19376.1.9.1.3.9.2 IHE Substitution Act Content Module\n// Substitution (Dispense)\ngroup SubstitutionDispense(source substitution : Substitution, target act : Act) {\n substitution -> act.classCode = 'ACT' "ACT";\n substitution -> act.moodCode = 'EVN' "EVN";\n substitution -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.2' "templateId";\n substitution.type as type -> act.code as code then CodeableConceptCE(type, code) "substitution";\n substitution -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode";\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US\ngroup ManufacturedMaterialEntryContentModuleDispense(source bundle : Bundle, source medicationDispense : MedicationDispense, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial) {\n medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT";\n medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND";\n medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule";\n medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId";\n medication.code as code then {\n code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname";\n } "name";\n medication.code as code then {\n // #dis.no.brandedmedication\n code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then {\n extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference";\n } "id";\n code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference";\n code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code";\n };\n medication.form as form then {\n form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode";\n };\n medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then {\n code -> containerPackagedMedicine.classCode = 'CONT' "CONT";\n code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE";\n code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code";\n code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name";\n medication.form as form then {\n form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode";\n };\n // Package size\n medication.amount as amount then {\n amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then {\n numerator.value as value -> capacityQuantity.value = value;\n numerator.code as unit -> capacityQuantity.unit = unit "unit";\n };\n };\n };\n medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then {\n ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then {\n itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT";\n itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND";\n itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name";\n itemCodeableConcept.coding as coding then {\n coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode";\n };\n } "PharmSubstance";\n ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity);\n };\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationdispense.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.42\ngroup DispenseItemEntryContentModule(source bundle : Bundle, source medicationDispense : MedicationDispense, target supply : Supply) {\n medicationDispense -> supply.classCode = 'SPLY' "SPLY";\n medicationDispense -> supply.moodCode = 'EVN' "EVN";\n medicationDispense -> supply.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.42' "CH-PHARM-DispenseItemEntryContentModule";\n medicationDispense -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.4' "IHE-PHARM-DIS";\n medicationDispense -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.3' "supplyEntry";\n medicationDispense -> supply.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.34' "CCD";\n medicationDispense.identifier as identifier -> supply.id as id then IdentifierII(identifier, id) "id";\n medicationDispense.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> supply.text as text, text.reference as reference then {\n extension.valueUrl as valueUrl -> reference.value = valueUrl;\n } "narrativeLink";\n medicationDispense where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> supply.text as text, text.reference as reference, text.reference as reference, reference.value = '#refpdf' "reference";\n medicationDispense.contained as medication where ('#' + $this.id) in %medicationDispense.medicationReference.reference -> supply.product as product, product.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then {\n medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-TemplateId";\n medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-TemplateId";\n medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModuleDispense(bundle, medicationDispense, medication, manufacturedMaterial) "manufacturedMaterial";\n };\n // TODO: AUTHOR1 Medication Treatment Plan Author\n medicationDispense.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";\n // #24 missing template it if ch-emed-dosage-nonstructured\n medicationDispense where dosageInstruction.count() = 1 then {\n medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";\n } "onylonedosage";\n // dosage for normal dosing, as no sequences are present there\n medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal') then DosageInstructionsStartStopFrequencySupply(dosage, supply) "DosageSubstanceAdministration";\n // dosage for split dosing, as sequences are present there\n medicationDispense -> supply.entryRelationship as entryRelationship then {\n medicationDispense -> entryRelationship.substanceAdministration as substanceAdministration then {\n // split dosing (with sequences): effectiveTime (start/stop) & routeCode & consumable\n medicationDispense.dosageInstruction first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration then DosageInstructionsEntryStartStopRouteConsumable(dosage, entryRelationship, substanceAdministration) "DosageSubstanceAdministration";\n // split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable\n medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeEntryRelationship(dosage, entryRelationship) "DosageSubstanceAdministration";\n } "substanceAdministration";\n } "entryRelationship";\n // TODO: Precondition Criterion\n medicationDispense.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule";\n // Number of packages\n medicationDispense.quantity as quantity -> supply.quantity as supplyQuantity then {\n quantity.value as value -> supplyQuantity.value = value;\n };\n medicationDispense.note as note -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment";\n medicationDispense.substitution as substitution -> supply.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionDispense(substitution, act) "Substitution";\n}\n\n// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal\n// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.35\n// dosage for normal dosing (without sequences) (Dispense)\ngroup DosageInstructionsStartStopFrequencySupply(source dosage : Dosage, target supply : Supply) {\n dosage -> supply.entryRelationship as entryRelationship then {\n dosage -> entryRelationship.typeCode = 'COMP' "COMP";\n dosage -> entryRelationship.substanceAdministration as substanceAdministration then {\n dosage -> substanceAdministration.classCode = 'SBADM' "SBADM";\n dosage -> substanceAdministration.moodCode = 'INT' "INT";\n dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.6' "templateId";\n dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";\n dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd";\n dosage -> substanceAdministration as substanceAdministration then EffectiveTimeWhenNormal(dosage, substanceAdministration) "effectiveTimeWhen";\n dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode);\n dosage -> substanceAdministration as substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity";\n dosage -> substanceAdministration as substanceAdministration, substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";\n } "substanceAdministration";\n } "entryRelationship";\n}\n\n// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split\n// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36\n// dosage for split dosing: effectiveTime (start/stop) & routeCode & consumable (Dispense)\ngroup DosageInstructionsEntryStartStopRouteConsumable(source dosage : Dosage, target entryRelationship : entryRelationship, target substanceAdministration : SubstanceAdministration) {\n dosage -> entryRelationship.typeCode = 'COMP' "COMP";\n dosage -> substanceAdministration.classCode = 'SBADM' "SBADM";\n dosage -> substanceAdministration.moodCode = 'INT' "INT";\n dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.6' "templateId";\n dosage -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.9' "splitDose";\n dosage -> substanceAdministration as substanceAdministration then EffectiveTimeStartEnd(dosage, substanceAdministration) "effectiveTimeStartEnd";\n dosage.route as route -> substanceAdministration.routeCode as routeCode then CodeableConceptCE(route, routeCode);\n dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";\n}\n\n// source: http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split\n// target: https://art-decor.org/art-decor/decor-templates--ch-pharm-?id=2.16.756.5.30.1.1.10.4.36\n// dosage for split dosing: sequence number, effectiveTime (when), dose quantity, consumable (Dispense)\ngroup DosageInstructionsEntryDosageChangeEntryRelationship(source dosage : Dosage, target entryRelationship : entryRelationship) {\n dosage.sequence as sequence -> entryRelationship.sequenceNumber as sequenceNumber, sequenceNumber.value = sequence;\n dosage -> entryRelationship.substanceAdministration as substanceAdministration, substanceAdministration.classCode = 'SBADM', substanceAdministration.moodCode = 'INT' then {\n dosage as dosage -> substanceAdministration then EffectiveTimeWhenSplit(dosage, substanceAdministration) "effectiveTimeWhen";\n dosage as dosage -> substanceAdministration then DoseQuantity(dosage, substanceAdministration) "doseQuantity";\n dosage as dosage -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.manufacturedMaterial as manufacturedMaterial, manufacturedMaterial.nullFlavor = 'NA' "consumable";\n } "dosage";\n}\n\n// effective time when for normal dosage (Dispense, Statement, Prescription)\ngroup EffectiveTimeWhenNormal(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {\n dosage.timing as timing then {\n timing.repeat as repeat then {\n repeat where $this.when.count() = 1 -> substanceAdministration.effectiveTime = create('EIVL_TS') as effectiveTime, effectiveTime.operator = 'A' then {\n repeat.when as when -> effectiveTime.event as event, event.code = when;\n } "when";\n repeat where $this.when.count() > 1 -> substanceAdministration.effectiveTime = create('SXPR_TS') as effectiveTime, effectiveTime.operator = 'A' then {\n repeat.when first as when -> effectiveTime.comp = create('EIVL_TS') as comp then {\n when -> comp.event as event, event.code = when "when";\n } "comp";\n repeat.when not_first as when -> effectiveTime.comp = create('EIVL_TS') as comp, comp.operator = 'I' then {\n when -> comp.event as event, event.code = when "when";\n } "compnotfirst";\n } "when";\n };\n };\n}\n\n// effective time when for split dosage (Dispense, Statement, Prescription)\ngroup EffectiveTimeWhenSplit(source dosage : Dosage, target substanceAdministration : SubstanceAdministration) {\n dosage.timing as timing then {\n timing.repeat as repeat then {\n repeat where $this.when.count() = 1 -> substanceAdministration.effectiveTime = create('EIVL_TS') as effectiveTime then {\n repeat.when as when -> effectiveTime.event as event, event.code = when;\n } "when";\n repeat where $this.when.count() > 1 -> substanceAdministration.effectiveTime = create('SXPR_TS') as effectiveTime, effectiveTime.operator = 'A' then {\n repeat.when first as when -> effectiveTime.comp = create('EIVL_TS') as comp then {\n when -> comp.event as event, event.code = when "when";\n } "comp";\n repeat.when not_first as when -> effectiveTime.comp = create('EIVL_TS') as comp, comp.operator = 'I' then {\n when -> comp.event as event, event.code = when "when";\n } "compnotfirst";\n } "when";\n };\n };\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html\n// target: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module\ngroup SubstitutionRequest(source substitution : Substitution, target act : Act) {\n substitution -> act.classCode = 'ACT' "ACT";\n substitution -> act.moodCode = 'DEF' "DEF";\n substitution -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.1' "templateId";\n substitution.allowedCodeableConcept as allowedCC -> act.code as code then CodeableConceptCE(allowedCC, code) "substitution";\n substitution -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode";\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html\n// target: Substitution permission Contains 1.3.6.1.4.1.19376.1.9.1.3.9.1 IHE Substitution Permission Content Module\ngroup SubstitutionStatement(source extension : Extension, target act : Act) {\n extension -> act.classCode = 'ACT' "ACT";\n extension -> act.moodCode = 'DEF' "DEF";\n extension -> act.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.9.1' "templateId";\n extension.valueCodeableConcept as valueCC -> act.code as code then CodeableConceptCE(valueCC, code) "extension";\n extension -> act.statusCode as statusCode, statusCode.code = 'completed' "statusCode";\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38\ngroup PrescribedQuantity(source dispenseRequest : DispenseRequest, target supply : Supply) {\n dispenseRequest -> supply.classCode = 'SPLY' "SPLY";\n dispenseRequest -> supply.moodCode = 'RQO' "RQO";\n dispenseRequest -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.8' "templateId";\n dispenseRequest -> supply.independentInd as independentInd, independentInd.value = 'false' "independentInd";\n // Number of packages\n dispenseRequest.quantity as quantity -> supply.quantity as quant then {\n quantity.value as value -> quant.value = value;\n };\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?id=2.16.756.5.30.1.1.10.4.38\ngroup PrescribedQuantityUnit(source dispenseRequest : DispenseRequest, target supply : Supply) {\n dispenseRequest -> supply.classCode = 'SPLY' "SPLY";\n dispenseRequest -> supply.moodCode = 'RQO' "RQO";\n dispenseRequest -> supply.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.8' "TemplateId";\n dispenseRequest -> supply.independentInd as independentInd, independentInd.value = 'false' "independentInd";\n // Number of packages\n dispenseRequest.quantity as quantity -> supply.quantity as quant then {\n quantity.value as value -> quant.value = value;\n quantity.unit as unit -> quant.unit = unit;\n };\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33\ngroup ManufacturedMaterialEntryContentModulePrescription(source bundle : Bundle, source medicationRequest : MedicationRequest, source medication : Medication, target manufacturedMaterial : ManufacturedMaterial, target substanceAdministration : SubstanceAdministration) {\n medication -> manufacturedMaterial.classCode = 'MMAT' "MMAT";\n medication -> manufacturedMaterial.determinerCode = 'KIND' "KIND";\n medication -> manufacturedMaterial.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.33' "CH-PHARM-ManufacturedMaterialContentModule";\n medication -> manufacturedMaterial.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.1' "templateId";\n medication.code as code then {\n code.text as text -> manufacturedMaterial.name as name, name.other = text "brandname";\n } "name";\n medication.code as code then {\n // #pre.no.brandedmedication\n code.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> manufacturedMaterial.code as code then {\n extension.valueUrl as valueUrl -> code.originalText as text, text.reference as reference, reference.value = valueUrl "reference";\n } "id";\n code where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> manufacturedMaterial.code as code, code.originalText as text, text.reference as reference, reference.value = '#refpdf' "reference";\n code.coding as coding -> manufacturedMaterial.code as ce then CodingCE(coding, ce) "code";\n };\n medication.form as form then {\n form.coding as coding -> manufacturedMaterial.formCode as formCode then CodingCE(coding, formCode) "formCode";\n };\n medication.code as code -> manufacturedMaterial.asContent as asContent, asContent.classCode = 'CONT', asContent.containerPackagedMedicine as containerPackagedMedicine then {\n code -> containerPackagedMedicine.classCode = 'CONT' "CONT";\n code -> containerPackagedMedicine.determinerCode = 'INSTANCE' "INSTANCE";\n code.coding as coding -> containerPackagedMedicine.code as ce then CodingCE(coding, ce) "pharm-code";\n code.text as text -> containerPackagedMedicine.name as name, name.other = text "pharm-name";\n medication.form as form then {\n form.coding as coding -> containerPackagedMedicine.formCode as formCode then CodingCE(coding, formCode) "pharm-formCode";\n };\n // Package size\n medication.amount as amount then {\n amount.numerator as numerator -> containerPackagedMedicine.capacityQuantity as capacityQuantity then {\n numerator.value as value -> capacityQuantity.value = value;\n numerator.code as unit -> capacityQuantity.unit = unit "unit";\n };\n // IHE-DIS: Case 1: If the product-element contains package information, the unit attribute is not be present\n medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.supply as supply then PrescribedQuantity(dispenseRequest, supply) "PrescribedQuantity";\n };\n // IHE-DIS: Case 2: If the product-element does not contain package information, the unit attribut is present and the value SHALL be out of the UCUM code system\n medication where $this.amount.exists() = false then {\n medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.supply as supply then PrescribedQuantityUnit(dispenseRequest, supply) "PrescribedQuantityUnit";\n } "noAmount";\n };\n medication.ingredient as ingredient -> manufacturedMaterial.ingredient as ingredient, ingredient.classCode = 'ACTI' then {\n ingredient.itemCodeableConcept as itemCodeableConcept -> ingredient.ingredient as pharmsubstance then {\n itemCodeableConcept -> pharmsubstance.classCode = 'MMAT' "MMAT";\n itemCodeableConcept -> pharmsubstance.determinerCode = 'KIND' "KIND";\n itemCodeableConcept.text as text -> pharmsubstance.name as name, name.other = text "name";\n itemCodeableConcept.coding as coding then {\n coding -> pharmsubstance.code as ce then CodingCE(coding, ce) "formCode";\n };\n } "PharmSubstance";\n ingredient.strength as strength -> ingredient.quantity as quantity then RatioRTOPQPQ(strength, quantity);\n };\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationrequest.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.43\ngroup PrescriptionItemEntryContentModule(source bundle : Bundle, source medicationRequest : MedicationRequest, target substanceAdministration : SubstanceAdministration) {\n medicationRequest -> substanceAdministration.classCode = 'SBADM' "SBADM";\n medicationRequest -> substanceAdministration.moodCode = 'INT' "INT";\n medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.43' "CH-PHARM-PrescriptionItemEntryContentModule";\n medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.2' "PrescriptionItemEntryTemplateId";\n medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.24' "CCD";\n medicationRequest -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7' "PCC-MedicationEntryContentModule";\n medicationRequest.identifier as identifier -> substanceAdministration.id as id then IdentifierII(identifier, id) "id";\n medicationRequest.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> substanceAdministration.text as text, text.reference as reference then {\n extension.valueUrl as valueUrl -> reference.value = valueUrl;\n } "narrativeLink";\n medicationRequest where extension.where(url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists().not() -> substanceAdministration.text as text, text.reference as reference then {\n medicationRequest -> reference.value = '#refpdf' "referencetopdf";\n } "cat1narrativelink";\n medicationRequest -> substanceAdministration.statusCode as statusCode, statusCode.code = 'completed' "code";\n medicationRequest.dispenseRequest as dispenseRequest -> substanceAdministration.repeatNumber as repeatNumber then {\n dispenseRequest.numberOfRepeatsAllowed as number -> repeatNumber.value = number "repeatNumber";\n dispenseRequest where numberOfRepeatsAllowed.exists() = false -> repeatNumber.nullFlavor = 'NI' "repeatNumberNull";\n };\n medicationRequest.contained as medication where ('#' + $this.id) in %medicationRequest.medicationReference.reference -> substanceAdministration.consumable as consumable, consumable.manufacturedProduct as manufacturedProduct, manufacturedProduct.classCode = 'MANU' then {\n medication -> manufacturedProduct.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.2' "MP-templateId";\n medication -> manufacturedProduct.templateId as templateId, templateId.root = '2.16.840.1.113883.10.20.1.53' "MP-templateId";\n medication -> manufacturedProduct.manufacturedMaterial as manufacturedMaterial then ManufacturedMaterialEntryContentModulePrescription(bundle, medicationRequest, medication, manufacturedMaterial, substanceAdministration) "manufacturedMaterial";\n };\n // TODO: AUTHOR1 Medication Treatment Plan Author\n medicationRequest where dosageInstruction.count() = 1 then {\n medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.5.3.1.4.7.1' "normalDose";\n } "onylonedosage";\n medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-normal-medicationrequest') then DosageInstructionsStartStopFrequencySubstanceAdministration(dosage, substanceAdministration) "DosageSubstanceAdministration";\n // dosage for split dosing (with sequences): effectiveTime (start/stop) & routeCode\n medicationRequest.dosageInstruction first as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split-medicationrequest') -> substanceAdministration.entryRelationship as entryRelationship then DosageInstructionsEntryStartStopRoute(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration";\n // dosage for split dosing (with sequences): sequence number, effectiveTime (when), dose quantity, consumable\n medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-structured-split-medicationrequest') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP' then DosageInstructionsEntryDosageChangeSubstanceAdministration(dosage, substanceAdministration, entryRelationship) "DosageSubstanceAdministration";\n medicationRequest.reasonCode as reasonCode -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'RSON', entryRelationship.observation as observation then TreatmentReasonEntryContentModule(reasonCode, observation) "TreatmentReasonEntryContentModule";\n medicationRequest.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";\n // TODO: Patient Medication Instructions Contains 1.3.6.1.4.1.19376.1.5.3.1.4.3 IHE Patient Medication Instructions (DYNAMIC)\n medicationRequest.dosageInstruction as dosage where $this.conformsTo('http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-dosage-nonstructured') -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.substanceAdministration as substanceAdministration then DosageInstructionsNonStructuredEntryContentModule(dosage, substanceAdministration) "DosageInstructionsNonStructuredEntryContentModule";\n medicationRequest.note as note -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then AnnotationComment(note, act) "AnnotationComment";\n medicationRequest.substitution as substitution -> substanceAdministration.entryRelationship as entryRelationship, entryRelationship.typeCode = 'COMP', entryRelationship.act as act then SubstitutionRequest(substitution, act) "Substitution";\n}\n\n// source: http://build.fhir.org/ig/hl7ch/ch-emed/StructureDefinition-ch-emed-observation.html\n// target: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.44\ngroup PharmaceuticalAdviceItemEntryContentModule(source bundle : Bundle, source fhirobservation : Observation, target cdaobservation : Observation) {\n fhirobservation -> cdaobservation.classCode = 'OBS' "OBS";\n fhirobservation -> cdaobservation.moodCode = 'EVN' "EVN";\n fhirobservation -> cdaobservation.templateId as templateId, templateId.root = '1.3.6.1.4.1.19376.1.9.1.3.3' "IHE-PHARM-PADV";\n fhirobservation -> cdaobservation.templateId as templateId, templateId.root = '2.16.756.5.30.1.1.10.4.44' "CH-PHARM-PharmaceuticalAdviceItemEntryContentModule";\n fhirobservation.identifier as identifier -> cdaobservation.id as id then IdentifierII(identifier, id) "id";\n fhirobservation.code as fhirCode -> cdaobservation.code as cdaCode then CodeableConceptCE(fhirCode, cdaCode);\n fhirobservation -> cdaobservation.statusCode as statusCode, statusCode.code = 'completed' "code";\n fhirobservation.effectiveDateTime as effectiveDateTime -> cdaobservation.effectiveTime as effectiveTime then {\n effectiveDateTime -> effectiveTime.value = effectiveDateTime "value";\n } "effectiveTime";\n fhirobservation.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-treatmentplan' -> cdaobservation.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR', entryRelationship.substanceAdministration as substanceAdministration then MTPReferenceEntryContentModule(extension, substanceAdministration) "MTP-Reference";\n fhirobservation.extension as extension where url = 'http://fhir.ch/ig/ch-emed/StructureDefinition/ch-emed-ext-medicationstatement-changed' -> cdaobservation.entryRelationship as entryRelationship, entryRelationship.typeCode = 'REFR' then {\n bundle.entry as entry then {\n entry.fullUrl where ($this in %extension.valueReference.reference) and $this.startsWith('urn:uuid') then {\n entry.resource as medicationStatement where $this.ofType(FHIR.MedicationStatement) -> entryRelationship.substanceAdministration as substanceAdministration then MedicationTreatmentPlanItemEntryContentModule(bundle, medicationStatement, substanceAdministration) "MedicationStatement";\n } "fullUrlAsUuid";\n entry.resource as medicationStatement where $this.ofType(FHIR.MedicationStatement) and (('MedicationStatement' + '/' + $this.id) in %extension.valueReference.reference) -> entryRelationship.substanceAdministration as substanceAdministration then MedicationTreatmentPlanItemEntryContentModule(bundle, medicationStatement, substanceAdministration) "MedicationStatement";\n };\n } "changedmtp";\n fhirobservation.note as note then {\n note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' -> cdaobservation.text as text, text.reference as reference then {\n extension.valueUrl as valueUrl -> reference.value = valueUrl;\n } "narrativeLink";\n note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> cdaobservation.text as text, text.reference as reference, reference.value = '#refpdf' "reference";\n };\n fhirobservation.note as note -> cdaobservation.text as text then {\n note.text as noteText -> text.data = noteText;\n note.extension as extension where $this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink' then {\n extension.valueUrl as valueUrl -> text.reference as reference, reference.value = valueUrl "reference";\n } "id";\n note where (extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false) -> text.reference as reference, reference.value = '#refpdf' "reference";\n } "text";\n}\n\n</pre>\n </div>"
},
"url" : "http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaChEmed",
"version" : "0.3.0",
"name" : "BundleToCdaChEmed",
"status" : "draft",
"date" : "2022-02-11T11:14:39+01:00",
"publisher" : "ahdis",
"contact" : [
{
"name" : "ahdis",
"telecom" : [
{
"system" : "url",
"value" : "http://www.ahdis.ch/"
}
]
}
],
"description" : "\r\nMedication Entries\r\n2020-11-11 Michaela Ziegler, copyright ahdis ag, Apache License\r\nCDA-CH-EMED: https://art-decor.org/art-decor/decor-project--cdachemed-\r\nFHIR CH-EMED: http://fhir.ch/ig/ch-emed/index.html\r\n",
"copyright" : "CC-BY-SA-4.0",
"structure" : [
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/ClinicalDocument",
"mode" : "target",
"alias" : "ClinicalDocument"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/AssignedAuthor",
"mode" : "target",
"alias" : "AssignedAuthor"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/AssignedEntity",
"mode" : "target",
"alias" : "AssignedEntity"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/Author",
"mode" : "target",
"alias" : "Author"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/CustodianOrganization",
"mode" : "target",
"alias" : "CustodianOrganization"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/IVL_TS",
"mode" : "target",
"alias" : "IVL_TS"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS",
"mode" : "target",
"alias" : "EIVL_TS"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/PatientRole",
"mode" : "target",
"alias" : "PatientRole"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/RecordTarget",
"mode" : "target",
"alias" : "RecordTarget"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/Section",
"mode" : "target",
"alias" : "Section"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/SubstanceAdministration",
"mode" : "target",
"alias" : "SubstanceAdministration"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS",
"mode" : "target",
"alias" : "SXPR_TS"
},
{
"url" : "http://hl7.org/fhir/cda/StructureDefinition/Supply",
"mode" : "target",
"alias" : "Supply"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Bundle",
"mode" : "source",
"alias" : "Bundle"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Composition",
"mode" : "source",
"alias" : "Composition"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Patient",
"mode" : "source",
"alias" : "Patient"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Practitioner",
"mode" : "source",
"alias" : "Practitioner"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Organization",
"mode" : "source",
"alias" : "Organization"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/MedicationStatement",
"mode" : "source",
"alias" : "MedicationStatement"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/Dosage",
"mode" : "source",
"alias" : "Dosage"
}
],
"import" : [
"http://fhir.ch/ig/cda-fhir-maps/StructureMap/FhirToCdaTypes",
"http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCda",
"http://fhir.ch/ig/cda-fhir-maps/StructureMap/BundleToCdaCh"
],
"group" : [
{
"name" : "AnnotationComment",
"typeMode" : "none",
"documentation" : "source: Annotation note (e.g. http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html)\r\ntarget: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.2",
"input" : [
{
"name" : "note",
"type" : "Annotation",
"mode" : "source"
},
{
"name" : "act",
"type" : "Act",
"mode" : "target"
}
],
"rule" : [
{
"name" : "ACT",
"source" : [
{
"context" : "note"
}
],
"target" : [
{
"context" : "act",
"contextType" : "variable",
"element" : "classCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "ACT"
}
]
}
]
},
{
"name" : "EVN",
"source" : [
{
"context" : "note"
}
],
"target" : [
{
"context" : "act",
"contextType" : "variable",
"element" : "moodCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "EVN"
}
]
}
]
},
{
"name" : "templateId",
"source" : [
{
"context" : "note"
}
],
"target" : [
{
"context" : "act",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "2.16.756.5.30.1.1.10.4.2"
}
]
}
]
},
{
"name" : "templateId",
"source" : [
{
"context" : "note"
}
],
"target" : [
{
"context" : "act",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "2.16.840.1.113883.10.20.1.40"
}
]
}
]
},
{
"name" : "templateId",
"source" : [
{
"context" : "note"
}
],
"target" : [
{
"context" : "act",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "1.3.6.1.4.1.19376.1.5.3.1.4.2"
}
]
}
]
},
{
"name" : "code",
"source" : [
{
"context" : "note"
}
],
"target" : [
{
"context" : "act",
"contextType" : "variable",
"element" : "code",
"variable" : "code"
},
{
"context" : "code",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueString" : "48767-8"
}
]
},
{
"context" : "code",
"contextType" : "variable",
"element" : "codeSystem",
"transform" : "copy",
"parameter" : [
{
"valueString" : "2.16.840.1.113883.6.1"
}
]
},
{
"context" : "code",
"contextType" : "variable",
"element" : "displayName",
"transform" : "copy",
"parameter" : [
{
"valueString" : "Annotation comment"
}
]
},
{
"context" : "code",
"contextType" : "variable",
"element" : "codeSystemName",
"transform" : "copy",
"parameter" : [
{
"valueString" : "LOINC"
}
]
}
]
},
{
"name" : "text",
"source" : [
{
"context" : "note",
"element" : "text",
"variable" : "noteText"
}
],
"target" : [
{
"context" : "act",
"contextType" : "variable",
"element" : "text",
"variable" : "text"
}
],
"rule" : [
{
"name" : "text",
"source" : [
{
"context" : "noteText"
}
],
"target" : [
{
"context" : "text",
"contextType" : "variable",
"element" : "data",
"transform" : "copy",
"parameter" : [
{
"valueId" : "noteText"
}
]
}
]
},
{
"name" : "id",
"source" : [
{
"context" : "note",
"element" : "extension",
"variable" : "extension",
"condition" : "$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"
}
],
"rule" : [
{
"name" : "reference",
"source" : [
{
"context" : "extension",
"element" : "valueUrl",
"variable" : "valueUrl"
}
],
"target" : [
{
"context" : "text",
"contextType" : "variable",
"element" : "reference",
"variable" : "reference"
},
{
"context" : "reference",
"contextType" : "variable",
"element" : "value",
"transform" : "copy",
"parameter" : [
{
"valueId" : "valueUrl"
}
]
}
]
}
]
},
{
"name" : "reference",
"source" : [
{
"context" : "note",
"condition" : "(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"
}
],
"target" : [
{
"context" : "text",
"contextType" : "variable",
"element" : "reference",
"variable" : "reference"
},
{
"context" : "reference",
"contextType" : "variable",
"element" : "value",
"transform" : "copy",
"parameter" : [
{
"valueString" : "#refpdf"
}
]
}
]
}
]
},
{
"name" : "statusCode",
"source" : [
{
"context" : "note"
}
],
"target" : [
{
"context" : "act",
"contextType" : "variable",
"element" : "statusCode",
"variable" : "code"
},
{
"context" : "code",
"contextType" : "variable",
"element" : "code",
"transform" : "copy",
"parameter" : [
{
"valueString" : "completed"
}
]
}
]
}
]
},
{
"name" : "ManufacturedMaterialEntryContentModuleStatement",
"typeMode" : "none",
"documentation" : "source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html\r\ntarget: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.33&effectiveDate=2019-12-11T11:34:24&language=en-US",
"input" : [
{
"name" : "bundle",
"type" : "Bundle",
"mode" : "source"
},
{
"name" : "medicationStatement",
"type" : "MedicationStatement",
"mode" : "source"
},
{
"name" : "medication",
"type" : "Medication",
"mode" : "source"
},
{
"name" : "manufacturedMaterial",
"type" : "ManufacturedMaterial",
"mode" : "target"
}
],
"rule" : [
{
"name" : "MMAT",
"source" : [
{
"context" : "medication"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "classCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "MMAT"
}
]
}
]
},
{
"name" : "KIND",
"source" : [
{
"context" : "medication"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "determinerCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "KIND"
}
]
}
]
},
{
"name" : "CH-PHARM-ManufacturedMaterialContentModule",
"source" : [
{
"context" : "medication"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "2.16.756.5.30.1.1.10.4.33"
}
]
}
]
},
{
"name" : "templateId",
"source" : [
{
"context" : "medication"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "1.3.6.1.4.1.19376.1.9.1.3.1"
}
]
}
]
},
{
"name" : "name",
"source" : [
{
"context" : "medication",
"element" : "code",
"variable" : "code"
}
],
"rule" : [
{
"name" : "brandname",
"source" : [
{
"context" : "code",
"element" : "text",
"variable" : "text"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "name",
"variable" : "name"
},
{
"context" : "name",
"contextType" : "variable",
"element" : "other",
"transform" : "copy",
"parameter" : [
{
"valueId" : "text"
}
]
}
]
}
]
},
{
"name" : "code",
"source" : [
{
"context" : "medication",
"element" : "code",
"variable" : "code"
}
],
"rule" : [
{
"name" : "id",
"source" : [
{
"context" : "code",
"element" : "extension",
"variable" : "extension",
"condition" : "$this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink'"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "code",
"variable" : "code"
}
],
"rule" : [
{
"name" : "reference",
"source" : [
{
"context" : "extension",
"element" : "valueUrl",
"variable" : "valueUrl"
}
],
"target" : [
{
"context" : "code",
"contextType" : "variable",
"element" : "originalText",
"variable" : "text"
},
{
"context" : "text",
"contextType" : "variable",
"element" : "reference",
"variable" : "reference"
},
{
"context" : "reference",
"contextType" : "variable",
"element" : "value",
"transform" : "copy",
"parameter" : [
{
"valueId" : "valueUrl"
}
]
}
]
}
],
"documentation" : "#mtpc.no.brandedmedication"
},
{
"name" : "reference",
"source" : [
{
"context" : "code",
"condition" : "(extension.where($this.url = 'http://hl7.org/fhir/StructureDefinition/narrativeLink').exists() = false)"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "code",
"variable" : "code"
},
{
"context" : "code",
"contextType" : "variable",
"element" : "originalText",
"variable" : "text"
},
{
"context" : "text",
"contextType" : "variable",
"element" : "reference",
"variable" : "reference"
},
{
"context" : "reference",
"contextType" : "variable",
"element" : "value",
"transform" : "copy",
"parameter" : [
{
"valueString" : "#refpdf"
}
]
}
]
},
{
"name" : "code",
"source" : [
{
"context" : "code",
"element" : "coding",
"variable" : "coding"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "code",
"variable" : "ce"
}
],
"dependent" : [
{
"name" : "CodingCE",
"variable" : [
"coding",
"ce"
]
}
]
},
{
"name" : "nullFlavor",
"source" : [
{
"context" : "code",
"condition" : "coding.exists() = false"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "code",
"variable" : "ce"
},
{
"context" : "ce",
"contextType" : "variable",
"element" : "nullFlavor",
"transform" : "copy",
"parameter" : [
{
"valueString" : "NA"
}
]
}
]
}
]
},
{
"name" : "form",
"source" : [
{
"context" : "medication",
"element" : "form",
"variable" : "form"
}
],
"rule" : [
{
"name" : "formCode",
"source" : [
{
"context" : "form",
"element" : "coding",
"variable" : "coding"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "formCode",
"variable" : "formCode"
}
],
"dependent" : [
{
"name" : "CodingCE",
"variable" : [
"coding",
"formCode"
]
}
]
}
]
},
{
"name" : "code",
"source" : [
{
"context" : "medication",
"element" : "code",
"variable" : "code"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "asContent",
"variable" : "asContent"
},
{
"context" : "asContent",
"contextType" : "variable",
"element" : "classCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "CONT"
}
]
},
{
"context" : "asContent",
"contextType" : "variable",
"element" : "containerPackagedMedicine",
"variable" : "containerPackagedMedicine"
}
],
"rule" : [
{
"name" : "CONT",
"source" : [
{
"context" : "code"
}
],
"target" : [
{
"context" : "containerPackagedMedicine",
"contextType" : "variable",
"element" : "classCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "CONT"
}
]
}
]
},
{
"name" : "INSTANCE",
"source" : [
{
"context" : "code"
}
],
"target" : [
{
"context" : "containerPackagedMedicine",
"contextType" : "variable",
"element" : "determinerCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "INSTANCE"
}
]
}
]
},
{
"name" : "pharm-code",
"source" : [
{
"context" : "code",
"element" : "coding",
"variable" : "coding"
}
],
"target" : [
{
"context" : "containerPackagedMedicine",
"contextType" : "variable",
"element" : "code",
"variable" : "ce"
}
],
"dependent" : [
{
"name" : "CodingCE",
"variable" : [
"coding",
"ce"
]
}
]
},
{
"name" : "pharm-name",
"source" : [
{
"context" : "code",
"element" : "text",
"variable" : "text"
}
],
"target" : [
{
"context" : "containerPackagedMedicine",
"contextType" : "variable",
"element" : "name",
"variable" : "name"
},
{
"context" : "name",
"contextType" : "variable",
"element" : "other",
"transform" : "copy",
"parameter" : [
{
"valueId" : "text"
}
]
}
]
},
{
"name" : "form",
"source" : [
{
"context" : "medication",
"element" : "form",
"variable" : "form"
}
],
"rule" : [
{
"name" : "pharm-formCode",
"source" : [
{
"context" : "form",
"element" : "coding",
"variable" : "coding"
}
],
"target" : [
{
"context" : "containerPackagedMedicine",
"contextType" : "variable",
"element" : "formCode",
"variable" : "formCode"
}
],
"dependent" : [
{
"name" : "CodingCE",
"variable" : [
"coding",
"formCode"
]
}
]
}
]
},
{
"name" : "amount",
"source" : [
{
"context" : "medication",
"element" : "amount",
"variable" : "amount"
}
],
"rule" : [
{
"name" : "numerator",
"source" : [
{
"context" : "amount",
"element" : "numerator",
"variable" : "numerator"
}
],
"target" : [
{
"context" : "containerPackagedMedicine",
"contextType" : "variable",
"element" : "capacityQuantity",
"variable" : "capacityQuantity"
}
],
"rule" : [
{
"name" : "value",
"source" : [
{
"context" : "numerator",
"element" : "value",
"variable" : "value"
}
],
"target" : [
{
"context" : "capacityQuantity",
"contextType" : "variable",
"element" : "value",
"transform" : "copy",
"parameter" : [
{
"valueId" : "value"
}
]
}
]
},
{
"name" : "unit",
"source" : [
{
"context" : "numerator",
"element" : "code",
"variable" : "unit"
}
],
"target" : [
{
"context" : "capacityQuantity",
"contextType" : "variable",
"element" : "unit",
"transform" : "copy",
"parameter" : [
{
"valueId" : "unit"
}
]
}
]
}
]
}
],
"documentation" : "Package size"
}
]
},
{
"name" : "ingredient",
"source" : [
{
"context" : "medication",
"element" : "ingredient",
"variable" : "ingredient"
}
],
"target" : [
{
"context" : "manufacturedMaterial",
"contextType" : "variable",
"element" : "ingredient",
"variable" : "ingredient"
},
{
"context" : "ingredient",
"contextType" : "variable",
"element" : "classCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "ACTI"
}
]
}
],
"rule" : [
{
"name" : "PharmSubstance",
"source" : [
{
"context" : "ingredient",
"element" : "itemCodeableConcept",
"variable" : "itemCodeableConcept"
}
],
"target" : [
{
"context" : "ingredient",
"contextType" : "variable",
"element" : "ingredient",
"variable" : "pharmsubstance"
}
],
"rule" : [
{
"name" : "MMAT",
"source" : [
{
"context" : "itemCodeableConcept"
}
],
"target" : [
{
"context" : "pharmsubstance",
"contextType" : "variable",
"element" : "classCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "MMAT"
}
]
}
]
},
{
"name" : "KIND",
"source" : [
{
"context" : "itemCodeableConcept"
}
],
"target" : [
{
"context" : "pharmsubstance",
"contextType" : "variable",
"element" : "determinerCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "KIND"
}
]
}
]
},
{
"name" : "name",
"source" : [
{
"context" : "itemCodeableConcept",
"element" : "text",
"variable" : "text"
}
],
"target" : [
{
"context" : "pharmsubstance",
"contextType" : "variable",
"element" : "name",
"variable" : "name"
},
{
"context" : "name",
"contextType" : "variable",
"element" : "other",
"transform" : "copy",
"parameter" : [
{
"valueId" : "text"
}
]
}
]
},
{
"name" : "coding",
"source" : [
{
"context" : "itemCodeableConcept",
"element" : "coding",
"variable" : "coding"
}
],
"rule" : [
{
"name" : "formCode",
"source" : [
{
"context" : "coding"
}
],
"target" : [
{
"context" : "pharmsubstance",
"contextType" : "variable",
"element" : "code",
"variable" : "ce"
}
],
"dependent" : [
{
"name" : "CodingCE",
"variable" : [
"coding",
"ce"
]
}
]
}
]
}
]
},
{
"name" : "strength",
"source" : [
{
"context" : "ingredient",
"element" : "strength",
"variable" : "strength"
}
],
"target" : [
{
"context" : "ingredient",
"contextType" : "variable",
"element" : "quantity",
"variable" : "quantity"
}
],
"dependent" : [
{
"name" : "RatioRTOPQPQ",
"variable" : [
"strength",
"quantity"
]
}
]
}
]
}
]
},
{
"name" : "MedicationTreatmentPlanItemEntryContentModule",
"typeMode" : "none",
"documentation" : "source: http://build.fhir.org/ig/hl7ch/ch-emed/branches/master/StructureDefinition-ch-emed-medicationstatement.html\r\ntarget: https://art-decor.org/art-decor/decor-templates--cdachemed-?section=templates&id=2.16.756.5.30.1.1.10.4.34&effectiveDate=2019-12-11T11:31:52&language=en-US",
"input" : [
{
"name" : "bundle",
"type" : "Bundle",
"mode" : "source"
},
{
"name" : "medicationStatement",
"type" : "MedicationStatement",
"mode" : "source"
},
{
"name" : "substanceAdministration",
"type" : "SubstanceAdministration",
"mode" : "target"
}
],
"rule" : [
{
"name" : "SBADM",
"source" : [
{
"context" : "medicationStatement"
}
],
"target" : [
{
"context" : "substanceAdministration",
"contextType" : "variable",
"element" : "classCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "SBADM"
}
]
}
]
},
{
"name" : "INT",
"source" : [
{
"context" : "medicationStatement"
}
],
"target" : [
{
"context" : "substanceAdministration",
"contextType" : "variable",
"element" : "moodCode",
"transform" : "copy",
"parameter" : [
{
"valueString" : "INT"
}
]
}
]
},
{
"name" : "CH-PHARM-MedicationTreatmentPlanItemEntryContentModule",
"source" : [
{
"context" : "medicationStatement"
}
],
"target" : [
{
"context" : "substanceAdministration",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "2.16.756.5.30.1.1.10.4.34"
}
]
}
]
},
{
"name" : "IHE-PHARM-MTP",
"source" : [
{
"context" : "medicationStatement"
}
],
"target" : [
{
"context" : "substanceAdministration",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "1.3.6.1.4.1.19376.1.9.1.3.7"
}
]
}
]
},
{
"name" : "CCD",
"source" : [
{
"context" : "medicationStatement"
}
],
"target" : [
{
"context" : "substanceAdministration",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "2.16.840.1.113883.10.20.1.24"
}
]
}
]
},
{
"name" : "PCC-MedicationEntryContentModule",
"source" : [
{
"context" : "medicationStatement"
}
],
"target" : [
{
"context" : "substanceAdministration",
"contextType" : "variable",
"element" : "templateId",
"variable" : "templateId"
},
{
"context" : "templateId",
"contextType" : "variable",
"element" : "root",
"transform" : "copy",
"parameter" : [
{
"valueString" : "1.3.6.1.4.1.19376.1.5.3.1.4.7"
}
]
}
]
},
{
"name" : "id",
"source" : [
{
"context" : "medicationStatement",
"element" : "identifier",
"variable" : "identifier"
}
],
"target" : [
{
"context" : "substanceAdministration",
"contextType" : "variable",
&nbs